package com.hmall.clients.web;

import com.hmall.clients.pojo.Search;
import com.hmall.clients.service.SearchService;
import com.hmall.common.doc.ItemDoc;
import com.hmall.common.dto.PageDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/search")
public class SearchController {

    @Autowired
    private SearchService searchService;

    @PostMapping("/list")
    public PageDTO<ItemDoc> saveList(@RequestBody Search search){
        return searchService.getlist(search);
    }

    @GetMapping("/suggestion")
    List<String> suggestion(@RequestParam("key")String key){
        return searchService.getSuggest(key);
    }

    @PostMapping("/filters")
    Map<String,List<String>> filters(@RequestBody Search search){
        return searchService.filters(search);
    }
}
